package entity;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.ForceDiscriminator;

@Entity
@ForceDiscriminator
public class OrganizationElement {

	@Id
	@GeneratedValue
	private int id;
	
	private String name;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Usuario admin;
	
	@OneToMany(mappedBy="organization")
	@Cascade({CascadeType.ALL, CascadeType.DELETE_ORPHAN})
	private List<StrategicPerspective> perspectives;
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "Usuario_OrganizationElement", joinColumns = @JoinColumn(name="OrganizationElement_id"), 
			   inverseJoinColumns = @JoinColumn(name="Usuario_id"))
	@Cascade({CascadeType.ALL})
	private List<Usuario> users;
	
	public void setId(int id) {
		this.id = id;
	}
	
	public int getId() {
		return id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setAdmin(Usuario admin) {
		this.admin = admin;
	}

	public Usuario getAdmin() {
		return admin;
	}

	public void setPerspectives(List<StrategicPerspective> perspectives) {
		this.perspectives = perspectives;
	}

	public List<StrategicPerspective> getPerspectives() {
		return perspectives;
	}

	public void setUsers(List<Usuario> users) {
		this.users = users;
	}

	public List<Usuario> getUsers() {
		return users;
	}
}
